<?php
 /*********************************************\
 |* @author Yannic Schnetz, Mike Waldvogel    *|
 |* @copyright Yannic Schnetz, Mike Waldvogel *|
 |*********************************************|
 |* @since 30.07.2013                         *|
 \*********************************************/


// SPEICHERN
if(isset($_POST['impressum_submit'])) {
    $text = Functions::filter_text($_POST['editor']);
    
    $num = $DB->num("SELECT * FROM `texts` LIMIT 1");
    if($num > 0) {
        $q = $DB->query("UPDATE `texts` SET `impressum` = '" . $text . "'");
    } else {
        $q = $DB->query("INSERT INTO `texts` (`impressum`) VALUES ('" . $text . "')");
    }
    
    if(!$q) {
        $tpl->assign('ERROR', 'MySQL-Fehler: <br /><br />' . $DB->last_error);
    } else {
        $tpl->assign('SUCCESS', 'Erfolgreich gespeichert!');
    }
}

// GET TEXT
$fetch = $DB->fetch("SELECT `impressum` FROM `texts` LIMIT 1");
$tpl->assign('data', $fetch);
?>
